<?php
/*
	插件概览
*/
defined('BY_JYA') or exit('error');
$_RQ['op']=$_RQ['op']?$_RQ['op']:'get';
if($_RQ['op']=='get'){
	if($_SESSION['os']=='windows'){
		$return['session_id']=session_id();
	}
	$_SESSION['logout_forward']='jy_51job/register/';
	$_SESSION['forward_url']='jy_51job/register/'; 
	$return['forward_url']=base64_encode($_SESSION['forward_url']);
	set_html('title','企业注册');
	exi($return);
}
if($_RQ['op']=='post'){
	$post=get_postdata();
	if(!$post['password'] || !$post['name']){
		exi('请填写账户名和密码','error');
	}
	if($post['name'] == $post['password']){
		exi('账号跟密码不能相同！','error');
	}
	if(!$post['password'] || !$post['password2']){
		exi('请输入密码！','error');
	}
	if($post['password'] != $post['password2']){
		exi('两次输入密码不一致！','error');
	}
	$tablename='jy_51job_merch_account';
	$user=pdo_get($tablename,array('uniacid'=>$_SESSION['uniacid'],'name'=>$post['name']));
	if($user['id']){
		exi('该账号已存在！','error');
	}
	$data=array(
		'name'=>trim($post['name']),
		'status'=>1,
	);
	$data['password']=md5($post['password']);
	$data['uniacid']=$_SESSION['uniacid'];
	$data['createtime']=time();
	pdo_insert('jy_51job_merch_account',$data);
	$url='jy_51job/login/';
	exi('注册成功!','',$url);
}